
cd ""

use "coups_data_clean_final.dta", clear

xtset leaderspell t_leader

***************************

gen post_t = 0 if f24.coup_fail == 1
bys leaderspell: replace post_t = l.post_t + 1 if l.post_t != . & l.post_t < 60
order post_t

gen post_t_colpus = 0 if f24.colpus_fail == 1
bys leaderspell: replace post_t_colpus = l.post_t_colpus + 1 if l.post_t != . & l.post_t_colpus < 60
order post_t_colpus

******************************************************
** 	Main leaderspell models, PT lagged 1 year
****************************************************** 

// Immediately after a coup:
xtreg latent_personalism l12.post_fail if post_t!=., fe cl(leaderspell)
xtreg latent_personalism l12.post_fail lgdppc growth oil_new milex if post_t!=., fe cl(leaderspell)
	
// General model before and after a coup:
xtreg latent_personalism l12.post_fail, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail t_leader lgdppc growth oil_new milex i.year, fe cl(leaderspell)

// General model before and after a coup, only if failed coup happened:
xtreg latent_personalism l12.post_fail if max_failed_coups>0, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail t_leader lgdppc growth oil_new milex i.year if max_failed_coups>0, fe cl(leaderspell)
 
// Immediately after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail if post_t!=. & max_any_coups>0, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail lgdppc growth oil_new milex if post_t!=. & max_any_coups>0, fe cl(leaderspell)

// General model before and after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail if max_any_coups>0, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail t_leader lgdppc growth oil_new milex i.year if max_any_coups>0, fe cl(leaderspell)
 

* Mixed effects with regime fixed effects 
xtreg latent_personalism l12.post_fail lgdppc growth oil_new milex i.id if post_t!=., cl(leaderspell)

* Mixed effects with country fixed effects 
xtreg latent_personalism l12.post_fail lgdppc growth oil_new milex i.ccode if post_t!=., cl(leaderspell)
 
 
******************************************************
** 	Autorregressive robust PT lagged 1 year
****************************************************** 

** Main leaderspell models, lagged 1 year and autorregressive

// Immediately after a coup:
xtreg latent_personalism l12.post_fail l12.latent_personalism if post_t!=., fe cl(leaderspell)

// General model before and after a coup:
xtreg latent_personalism l12.post_fail l12.latent_personalism i.year, fe cl(leaderspell)

// General model before and after a coup, only if failed coup happened:
xtreg latent_personalism l12.post_fail l12.latent_personalism i.year if max_failed_coups>0, fe cl(leaderspell)

// Immediately after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail l12.latent_personalism if post_t!=. & max_any_coups>0, fe cl(leaderspell)

// General model before and after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail l12.latent_personalism i.year if max_any_coups>0, fe cl(leaderspell)


******************************************************
** 	Main leaderspell models, COLPUS lagged 1 year
****************************************************** 


// Immediately after a coup:
xtreg latent_personalism l12.post_fail_colpus if post_t_colpus!=., fe cl(leaderspell)
xtreg latent_personalism l12.post_fail_colpus lgdppc growth oil_new milex if post_t_colpus!=., fe cl(leaderspell)
	
// General model before and after a coup:
xtreg latent_personalism l12.post_fail_colpus, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail_colpus t_leader lgdppc growth oil_new milex i.year, fe cl(leaderspell)

// General model before and after a coup, only if failed coup happened:
xtreg latent_personalism l12.post_fail_colpus if max_failed_coups>0, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail_colpus t_leader lgdppc growth oil_new milex i.year if max_failed_coups>0, fe cl(leaderspell)
 
// Immediately after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail_colpus if post_t_colpus!=. & max_any_coups>0, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail_colpus lgdppc growth oil_new milex if post_t_colpus!=. & max_any_coups>0, fe cl(leaderspell)

// General model before and after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail_colpus if max_any_coups>0, fe cl(leaderspell)
xtreg latent_personalism l12.post_fail_colpus t_leader lgdppc growth oil_new milex i.year if max_any_coups>0, fe cl(leaderspell)
 

* Mixed effects with regime fixed effects 
xtreg latent_personalism l12.post_fail_colpus lgdppc growth oil_new milex i.id if post_t_colpus!=., cl(leaderspell)

* Mixed effects with country fixed effects 
xtreg latent_personalism l12.post_fail_colpus lgdppc growth oil_new milex i.ccode if post_t_colpus!=., cl(leaderspell)



******************************************************
** 	Autorregressive robust COLPUS lagged 1 year
****************************************************** 

** Main leaderspell models, lagged 1 year and autorregressive

// Immediately after a coup:
xtreg latent_personalism l12.post_fail_colpus l12.latent_personalism if post_t_colpus!=., fe cl(leaderspell)

// General model before and after a coup:
xtreg latent_personalism l12.post_fail_colpus l12.latent_personalism i.year, fe cl(leaderspell)

// General model before and after a coup, only if failed coup happened:
xtreg latent_personalism l12.post_fail_colpus l12.latent_personalism i.year if max_failed_coups>0, fe cl(leaderspell)

// Immediately after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail_colpus l12.latent_personalism if post_t_colpus!=. & max_any_coups>0, fe cl(leaderspell)

// General model before and after a coup, only if ANY coup happened:
xtreg latent_personalism l12.post_fail_colpus l12.latent_personalism i.year if max_any_coups>0, fe cl(leaderspell)


